const mysql  = require('mysql2/promise');
const {connection} = require('../modules/common');
const mime = require('mime-types');
const fs = require('fs');
const router = require('koa-router')();

router.get('/images/:name',async(ctx,next) => {
    let name = ctx.params.name;
    let addr = __dirname.replace('\/routes','');
    let filePath = `${addr}\/images\/${name}`
    let data = fs.readFileSync(filePath);
    let mimeType = mime.lookup(filePath);
    ctx.set('content-type',mimeType);
    ctx.body = data;
})

module.exports = router;

